<template>
  <div class="page_scroll">
    <el-form class="el_form" :model="addForm" label-width="200px" size="small">
      <h2 class="h2">公司基本信息设置</h2>
      <el-form-item label="公司简称：">
        <el-input v-model.trim="addForm.nickname"></el-input>
      </el-form-item>
      <el-form-item label="公司全称：">
        <el-input v-model.trim="addForm.name"></el-input>
      </el-form-item>
      <el-form-item label="公司地址：">
        <el-input v-model.trim="addForm.adress"></el-input>
      </el-form-item>
      <el-form-item label="公司信用编码：">
        <el-input v-model.trim="addForm.orgESign.orgNumber"></el-input>
      </el-form-item>
      <el-form-item label="开启自动分配客户：">
        <el-select v-model="addForm.automatic" placeholder="请选择">
          <el-option label="是" :value="1"></el-option>
          <el-option label="否" :value="2"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="客户状态：">
        <el-input v-model.trim="addForm.orgConfig.customerStatus"></el-input>
        <span class="input_tips">填写说明: 多个状态以,号隔开</span>
      </el-form-item>
      <el-form-item label="城市：">
        <el-input v-model.trim="addForm.orgConfig.city"></el-input>
        <span class="input_tips">填写说明: 多个城市以,号隔开</span>
      </el-form-item>
      <el-form-item label="媒体：">
        <el-input v-model.trim="addForm.orgConfig.media"></el-input>
        <span class="input_tips">填写说明: 多个媒体以,号隔开</span>
      </el-form-item>
      <el-form-item label="渠道产品：">
        <el-input v-model.trim="addForm.orgConfig.product"></el-input>
        <span class="input_tips">填写说明: 多个产品以,号隔开</span>
      </el-form-item>
      <el-form-item label="业务员客户上限：">
        <el-input v-model.trim="addForm.orgConfig.upperLimit"></el-input>
        <span class="input_tips">必填:数字</span>
      </el-form-item>
      <el-form-item label="多久未跟进客户放入公共池：">
        <el-input v-model.trim="addForm.orgConfig.recycleLimit"></el-input>
        <span class="input_tips">单位:天,必填数字</span>
      </el-form-item>
      <el-form-item label="多久未跟进客户统计配置：">
        <el-input v-model.trim="addForm.orgConfig.noProcess"></el-input>
        <span class="input_tips">多个配置以,号隔开</span>
      </el-form-item>
      <el-form-item label="锁定时效：">
        <el-input v-model.trim="addForm.orgConfig.lockDuration"></el-input>
        <span class="input_tips">单位:天</span>
      </el-form-item>
      <el-form-item label="限定ip地址登录：">
        <el-input v-model.trim="addForm.orgConfig.ip"></el-input>
      </el-form-item>
      
      
      
      <!-- <h2 class="h2">公司电子合同签约配置</h2> -->
      <!-- <el-form-item label="App Id：">
        <el-input v-model.trim="addForm.orgESign.appid"></el-input>
      </el-form-item>
      <el-form-item label="Secret：">
        <el-input v-model.trim="addForm.orgESign.secret"></el-input>
      </el-form-item>
      <el-form-item label="公司签章id：">
        <el-input v-model.trim="addForm.name"></el-input>
      </el-form-item>
      <el-form-item label="签约落章页：">
        <el-input v-model.trim="addForm.orgESign.posPage"></el-input>
      </el-form-item>
      <el-form-item label="签约落章位置X轴：">
        <el-input v-model.trim="addForm.orgESign.x"></el-input>
      </el-form-item>
      <el-form-item label="签约落章位置Y轴：">
        <el-input v-model.trim="addForm.orgESign.y"></el-input>
      </el-form-item> -->
      <!-- <el-form-item label="是否自动落章：">
        <el-select v-model="addForm.orgESign.auto" placeholder="请选择">
          <el-option label="是" :value="1"></el-option>
          <el-option label="否" :value="0"></el-option>
        </el-select>
      </el-form-item> -->
      <!-- <el-form-item label="签约状态回调地址：">
        <el-input v-model.trim="addForm.orgESign.noticeUrl"></el-input>
      </el-form-item>
      <el-form-item label="签约成功后重定向地址：">
        <el-input v-model.trim="addForm.orgESign.redirectUrl"></el-input>
      </el-form-item> -->
      <el-form-item label="">
        <el-button type="primary" :loading="loading" @click="updateInfo">保存修改</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import { GET_ORGCONFIG_INFO, UPDATE_ORGCONFIG_INFO } from "@/http/customer";
import { showToast, deepClone } from "@/utils/util";
export default {
  data() {
    return {
      addForm: { orgESign: {}, orgConfig: {} },
      loading: false,
    };
  },
  mounted() {
    this.getInfo();
  },
  methods: {
    // 获取配置信息
    getInfo() {
      GET_ORGCONFIG_INFO().then((res) => {
        let obj = res.data || {};
        if (!obj.orgESign) {
          obj.orgESign = {};
        }

        if (!obj.orgConfig) {
          obj.orgConfig = {};
        }

        this.addForm = obj;
      });
    },

    // 更新配置
    updateInfo() {
      let oParams = deepClone(this.addForm);
      this.loading = true;
      UPDATE_ORGCONFIG_INFO(oParams).then((res) => {
        this.loading = false;
        if (res.code == 200) {
          showToast({
            message: res.message,
            type: "success",
          });
        }
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.el_form {
  padding: 30px;
  .h2 {
    font-size: 16px;
    font-weight: 600;
    color: #333;
  }
  .el-input {
    width: 360px;
  }
}
.input_tips {
  font-size: 12px;
  color: #999;
  margin-left: 10px;
}
</style>